﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MoneyManagerNET.Model
{
    public enum AssetChangeInValueType : byte { None, Appreciate, Deppreciate }
    public static class AssetExtension
    {
        public static decimal GetCurrentValue(this IAsset asset)
        {
            switch ((AssetChangeInValueType)asset.ChangeInValue)
            {
                case AssetChangeInValueType.None:
                    return asset.Value;
                case AssetChangeInValueType.Appreciate:
                    return asset.Value + (decimal)((DateTime.Today - asset.Date).TotalDays * asset.Rate / 365);
                case AssetChangeInValueType.Deppreciate:
                    return asset.Value - (decimal)((DateTime.Today - asset.Date).TotalDays * asset.Rate / 365);
            }
            return Decimal.Zero;
        }
    }
}
